package com.numbfish.ch16_ex06_web_flux.controller;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.time.Duration;

@RestController
public class SSEController {
    // http://localhost:8080/sse
    @GetMapping(value = "/sse",produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> sse(){
        return Flux.range(1,10).map(i->i+"哈哈").delayElements(Duration.ofMillis(500));
    }
}
